
// code for BasecampNavigator.mxml

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

import flash.events.Event;

import navigator.State;

import summit.basecamp.constants.CommentableType;
import summit.basecamp.wrappers.CategoryWrapper;
import summit.basecamp.wrappers.CommentWrapper;
import summit.basecamp.wrappers.CompanyWrapper;
import summit.basecamp.wrappers.MessageWrapper;
import summit.basecamp.wrappers.MilestoneWrapper;
import summit.basecamp.wrappers.PersonWrapper;
import summit.basecamp.wrappers.ProjectWrapper;
import summit.basecamp.wrappers.TimeEntryWrapper;
import summit.basecamp.wrappers.TodoItemWrapper;
import summit.basecamp.wrappers.TodoListWrapper;

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

/** @private Called by the system once every thing is ready. */
private function handleApplicationCompleteEvent():void
{
	// State is a basic object made up of static references that are shared
	// with all elements in the application.
	//
	// Assigning references here will expose these to use by all of the 
	// components in the system.
	
	State.tree 		= tree;					
	State.viewer 	= propertiesViewer;
	State.login		= loginScreen;
	
	State.projectWrapper = new ProjectWrapper();
	
	// Dynamic calls are used throughout the rest of the application. Wrappers
	// are invoked here to ensure they are available for dynamic usage.
	new CategoryWrapper();
	new CommentWrapper();
	new CompanyWrapper();
	new MessageWrapper();
	new MilestoneWrapper();
	new PersonWrapper();
	new ProjectWrapper();
	new TimeEntryWrapper();
	new TodoItemWrapper();
	new TodoListWrapper();
	
	// Each UI component wires events as needed.
	State.tree.wireEvents();
	State.login.wireEvents();
	State.viewer.wireEvents();
	
	// Want to know when the user has attempted a log-in.
	State.login.addEventListener(Event.CONNECT, handleLoginConnectEvent);
}

/** @private Called when user attempts to connect to Basecamp. **/
private function handleLoginConnectEvent(e:Event):void
{
	State.projectWrapper.loader.accountToken = State.accountToken;
	State.projectWrapper.list();
}
//////////////////////////////////////////////////////// gmarius@tyemill.com //